﻿<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace=" System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="TarreOA.TarreOAModels" %>
<%@ Import Namespace="TarreOA.TarreOABLL" %>

<script runat="server">

    private string selectpath;
    private string catalogName;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] == null)
        {
            Response.Redirect("~/Login.aspx");
        }
        else
        {
            if (!Page.IsPostBack)
            {
                //if (Session["cp"] != null)
                //{
                //    ndcP = Session["cP"].ToString();
                //    Session.Remove("cP"); 
                //} 
                if (Request["c_N"] != null && Request.QueryString.Get("c_id") != null)
                {
                    catalogName = Request["c_N"];
                     this.BtnRetu.Attributes.Add("c_id", Request.QueryString.Get("c_id"));
                }
                this.selectpath = Request.Params.GetValues("DropDownList1")[0];
                AddFolderDdl();
                ViewState["catalogName"] = catalogName;
            }
        }   
    }

    private void AddFolderDdl()
    {
        this.DdlFolderPlace.Items.Clear();
        NetDiskCatalogFolderAndFileService ndcfafService = new NetDiskCatalogFolderAndFileService();
        string cp = FindConfigurationPath.instance().NetDiskRoots[catalogName].ToString();
        List<string> list = ndcfafService.findCurrentCatalogAllFolder(cp);
        ListItem rootItem = new ListItem("\\", "");
        this.DdlFolderPlace.Items.Add(rootItem);
        if (list != null)
        {
            foreach (string pathAndName in list)
            {
                string[] pan = pathAndName.Split(',');
                ListItem listItem = new ListItem(pan[1], pan[0].Replace(cp, ""));
                this.DdlFolderPlace.Items.Add(listItem);
                if (this.selectpath != null && this.selectpath.Equals(listItem.Value))
                {
                    listItem.Selected = true;
                }
            }
        }
    }
    protected void BtnCreate_Click(object sender, EventArgs e)
    {
        if (ViewState["catalogName"] != null)
        {
            catalogName = (string)ViewState["catalogName"]; 
        }  
        string curPlace = FindConfigurationPath.instance().NetDiskRoots[catalogName].ToString() +
            Request.Params.GetValues(this.DdlFolderPlace.ClientID)[0];
        if (!"".Equals(this.TxtFolderName.Text.Trim()))
        {
            string folderName = curPlace + "\\" + this.TxtFolderName.Text;
            if (!"".Equals(curPlace))
            {
                DirectoryInfo dirInfo = new DirectoryInfo(folderName);
                if (dirInfo.Exists)
                {
                    dirInfo.Delete(true);
                }
                dirInfo.Create();
                this.TxtFolderName.Text = "";
                this.AddFolderDdl();
            }
        }
        ViewState["catalogName"] = catalogName; 
    }

    protected void BtnRetu_Click(object sender, EventArgs e)
    {
        if (ViewState["catalogName"] != null)
        {
            catalogName = (string)ViewState["catalogName"]; 
        }
        string c_id = ((Button)sender).Attributes["c_id"]; 
        Response.Redirect("NetDiskCatalogFolderShow.aspx?C_N=" + catalogName + "&C_ID=" + c_id);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script type="text/javascript" src="../js/NetDisk.js"></script>
    
                    <link rel="Stylesheet" type="text/css" href="../Styles/right_style.css" />
                <script type="text/javascript" src="../Scripts/jquery.ui/js/jquery.js"></script>

                <style type="text/css">
                <!--
                html{ scrollbar-base-color: #dbecf8; scrollbar-arrow-color: #2a8ed1; scrollbar-track-color: #bdddf2; scrollbar-3dlight-color: #2886c5; scrollbar-darkshadow-color: #2886c5;
                scrollbar-face-color: #dbecf8; scrollbar-shadow-color: #dbecf8;  }
                -->
                </style>


</head>
<body>
    <form id="form1" runat="server">
            <div class="sub_right_top">
  <div class="hdm_header" >
    <div class="tb1_on"><h2 class="h2_icon">网络硬盘</h2></div>

    <div class="clear"></div>
  </div>
  <div class="hdm_footer">
    <div style="height:13px; overflow:hidden;"></div>
      
      <div style="height:10px; overflow:hidden;"></div>
          <table width="97%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#77acd0" style="border-collapse:collapse;">
            <tr bgcolor="#b1d5ef">
                <td colspan="2" nowrap="nowrap">
                    &nbsp;
                    <img align="absMiddle" border="0" src="../images/newfolder.gif" />
                    <font style="font-size:12px">新建文件夹<font color="red">(目标位置文件夹或文件如有重名将会覆盖)</font></font></td>
            </tr>
            <tr class="TableLine1">
                <td align="right" nowrap="nowrap" style="height: 16px">
                    <font style="font-size: 12px">位置：</font></td>
                <td nowrap="nowrap" style="height: 16px">
                    <asp:DropDownList ID="DdlFolderPlace" runat="server" Width="213px">
                    </asp:DropDownList></td>
            </tr>
            <tr class="TableLine1">
                <td align="right" nowrap="nowrap" style="height: 7px">
                    <font style="font-size: 12px">文件夹名称：</font></td>
                <td nowrap="nowrap" style="height: 7px">
                    <asp:TextBox ID="TxtFolderName" runat="server" Width="208px"></asp:TextBox></td>
            </tr>
            <tr>
                <td align="center" colspan="2" nowrap="nowrap">
                    <asp:Button ID="BtnCreate" runat="server" OnClick="BtnCreate_Click" OnClientClick="return checkNewCatalogFolderName('TxtFolderName')"
                        Text="" CssClass="queding_anniu"/>&nbsp;<asp:Button
                        ID="BtnRetu" runat="server" Text="" CssClass="fanhui_anniu" OnClick="BtnRetu_Click" /></td>
            </tr>
        </table>
        </div>
        </div>
    </form>
</body>
</html>
